<script setup>
import {ref} from 'vue'
import {Menu as IconMenu,} from '@element-plus/icons-vue'

const activeIndex = ref('1')
const handleSelect = (key, keyPath) => {
  console.log(key, keyPath)
}
//左侧菜单栏信息

const handleOpen = (key, keyPath) => {
  console.log(key, keyPath)
}
const handleClose = (key, keyPath) => {
  console.log(key, keyPath)
}
</script>

<template>
  <div class="home">
    <div class="home_header">
      <el-menu
          :default-active="activeIndex"
          class="el-menu-demo"
          mode="horizontal"
          :ellipsis="false"
          @select="handleSelect"
          router
      >
        <el-menu-item index="/">麦当劳商品销售管理平台</el-menu-item>
        <el-menu-item index="/login">登录</el-menu-item>
      </el-menu>
    </div>
    <div class="home_main">
      <div class="left_main">
        <el-menu
            default-active="2"
            class="el-menu-vertical-demo"
            @open="handleOpen"
            @close="handleClose"
            router
        >
          <el-menu-item index="/layout">
            <el-icon>
              <icon-menu/>
            </el-icon>
            <span>首页</span>
          </el-menu-item>
          <el-sub-menu index="/goods">
            <template #title>
              <el-icon>
                <icon-menu/>
              </el-icon>
              <span>商品管理</span>
            </template>
            <el-menu-item-group>

              <el-menu-item index="/goods">商品详情</el-menu-item>
            </el-menu-item-group>
            <el-menu-item-group>

              <el-menu-item index="/inventory">库存详情</el-menu-item>
            </el-menu-item-group>
          </el-sub-menu>
          <el-menu-item index="/order">
            <el-icon>
              <icon-menu/>
            </el-icon>
            <span>订单管理</span>
          </el-menu-item>
          <el-menu-item index="/user">
            <el-icon>
              <icon-menu/>
            </el-icon>
            <span>用户管理</span>
          </el-menu-item>
        </el-menu>


      </div>
      <div class="right_main">
        <!--        二级菜单路由-->
        <router-view></router-view>
      </div>
    </div>


  </div>
</template>
<style scoped lang="scss">
.home {
  width: 100%;
  height: 100%;

  .home_header {
  }

  .home_main {
    display: flex;

    .left_main {
      width: 200px;
    }

    .right_main {
      flex: 1;
      padding: 20px;
    }
  }
}


.el-menu--horizontal > .el-menu-item:nth-child(1) {
  margin-right: auto;
}
</style>
